﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using Microsoft.DirectX;
using Microsoft.DirectX.Direct3D;

namespace Space_Conquest
{

    /// <summary>
    /// 
    /// </summary>
    delegate void MenuButtonHandler();

    class MenuButton : IRender, IInput
    {

        #region Member Variables

        /// <summary>
        /// creates private variables
        /// </summary>
    
        private int _x;
        private int _y;
        private int _sizeX;
        private int _sizeY;
        private string _texture;
        private Texture _TestTexture;
        private Sprite _TestSprite;

        #endregion

        #region Events
        
        public event MenuButtonHandler OnButtonClick; 
        
        #endregion

        #region Constructor

            /// <summary>
            /// Creates GameButton constructor
            /// </summary>
            public MenuButton(int x, int y, int sizeX, int sizeY, string texture)
            {
                _x = x;
                _y = y;
                _sizeX = sizeX;
                _sizeY = sizeY;
                _texture = texture;
                _TestTexture = new Texture(_texture);
                _TestSprite = new Sprite(x, y, sizeX, sizeY, 255, true);
            }
        #endregion

        #region IRender Members

        /// <summary>
        /// Renders button texture and text
        /// </summary>
        public void Render()
        {
            _TestSprite.Render(_TestTexture);
        }

        #endregion

        #region IInput Members

        public bool MouseDown(System.Windows.Forms.MouseButtons button, int x, int y)
        {

            if (x > _TestSprite.Left && x < _TestSprite.Right)
            {
                if (y > _TestSprite.Top && y < _TestSprite.Bottom)
                {
                    if (OnButtonClick != null)
                    {
                        OnButtonClick();
                        return true;
                    }
                }
            }

            return false;
        }

        public bool MouseUp(System.Windows.Forms.MouseButtons button, int x, int y)
        {
            return false;
        }

        public bool MouseMove(int x, int y)
        {
            return false;
        }

        public bool KeyDown(System.Windows.Forms.Keys key, bool shift)
        {
            return false;
        }

        public bool KeyUp(System.Windows.Forms.Keys key, bool shift)
        {
            return false;
        }

        #endregion
    
    }
}
